/**
 * 0739
 *  
 * @Author : roryrywang
 * @DateTime : 2024/8/14 23:04
 */

#include <iostream>
#include <vector>
#include "stack"

using namespace std;

class Solution {
public:
    vector<int> dailyTemperatures(vector<int> &temperatures) {
        stack<int> st;
        vector<int> res(temperatures.size());
        for (int i = temperatures.size() - 1; i >= 0; --i) {
            while (!st.empty()) {
                if (temperatures[i] < temperatures[st.top()]) break;
                st.pop();
            }
            if (!st.empty()) res[i] = st.top() - i;
            st.push(i);
        }
        return res;
    }
};

int main() {

    return 0;
}